package com.example.sharding1.mapper;

import com.example.sharding1.entity.AccountEntity;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface AccountMapper {

    @Select("SELECT * FROM `account`")
    List<AccountEntity> getAll();

    @Select("SELECT * FROM `account` WHERE `user_id` = #{userId}")
    AccountEntity getByUserId(@Param("userId") Integer userId);

    @Insert("INSERT INTO `account` (`user_id`, `username`, `account_balance`, `status`) VALUES (#{userId}, #{username}, #{accountBalance}, 1)")
    int insert(AccountEntity accountEntity);

}
